﻿@page "/commoncontrols"

<ContentPage>
    <StackLayout Margin="new Thickness(20)">

        <Slider Minimum="0" Maximum="20" @bind-Value="SliderValue" />
        <Label>
            <Span>Slider is @_sliderValue</Span>
        </Label>

        <StackLayout Orientation="StackOrientation.Horizontal">
            <Button Text="Favorite?" OnClick="ToggleFavorite" />

            <Image Source="@(ImageSource.FromResource(isFavorite ? "ControlGallery.images.favorite.png" : "ControlGallery.images.not-favorite.png"))" />
        </StackLayout>
    </StackLayout>
</ContentPage>

@code
{
    private double _sliderValue;

    public double SliderValue
    {
        get
        {
            return _sliderValue;
        }
        set
        {
            if (_sliderValue != value)
            {
                _sliderValue = value;
            }
        }
    }

    bool isFavorite;

    void ToggleFavorite()
    {
        isFavorite = !isFavorite;
    }
}
